package com.modifiertech.lineage.api;


import com.feed_the_beast.ftblib.lib.icon.Icon;
import com.modifiertech.lineage.BaseConst;
import com.modifiertech.lineage.client.gui.ftbint.SkillInfo;
import com.modifiertech.lineage.event.PlayerDataHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**玩家数据技能抽象类
 * 玩家所有技能均需继承该类
 *
 */
public abstract class PlayerDataSkill extends IForgeRegistryEntry.Impl<PlayerDataSkill> implements IAbilityEventHandler, Serializable {
    //技能名称
    private String skillName;
    //技能类别
    private String skillType;
    //技能次级类别
    private String skillSecondType;
    //技能等级
    private int skillLevel=0;
    //是否可用
    private boolean isEnable=false;
    //依赖的人物等级
    private int levelDependency=0;
    //技能所在的区域（指ui分布）
    private int skillRegion=0;
    //技能描述
    private String skillDesc="默认描述";
    //当前技能依赖的技能名称列表
    private List<String> skillsDependencyName=new ArrayList<>();
    //冷却时间
    private int coolDown=-1;
    //魔法消耗
    private double manaUse = 0d;
    //升一级所消耗的点数
    private int upgradeCount = 1;



    //在技能树上的位置
    private double rowX,ColumnY;
    //图标
    private Icon icon;


    public PlayerDataSkill(){
        this.setIcon(defineSkillIcon());
        this.setSkillName(defineSkillName());
        this.setSkillType(defineSkillType());
        this.setSkillSecondType(defineSkillSecondType());
        this.setLevelDependency(defineSkillLevelDependency());
        this.setSkillRegion(defineSkillRegion());
        this.setSkillDesc(defineSkillDesc());
        this.setRowX(defineSkillRowX());
        this.setColumnY(defineSkillColumnY());
        this.setCoolDown(defineSkillCoolDown());
        this.setManaUse(defineSkillManaUse());
        this.setSkillsDependencyName(defineSkillDependencyName());
        this.setRegistryName(new ResourceLocation(BaseConst.MODID,defineSkillName()));
        this.setUpgradeCount(defineUpgradePoint());
    }

    // 拷贝构造函数
    public static PlayerDataSkill copy(PlayerDataSkill other) {
        PlayerDataSkill instance = null;
        try {
            instance = other.getClass().newInstance();
            instance.skillName = other.skillName;
            instance.skillLevel = other.skillLevel;
            instance.skillDesc = other.skillDesc;
            instance.icon = other.icon;
            instance.isEnable = other.isEnable;
            instance.ColumnY = other.ColumnY;
            instance.coolDown = other.coolDown;
            instance.levelDependency = other.levelDependency;
            instance.manaUse = other.manaUse;
            instance.rowX = other.rowX;
            instance.skillRegion=other.skillRegion;
            instance.skillsDependencyName = other.skillsDependencyName;
            instance.skillSecondType = other.skillSecondType;
            instance.skillType = other.skillType;
            instance.upgradeCount = other.upgradeCount;
        } catch (Exception ignore){}
        return instance;
    }



    /**使用的技能图标
     * @return
     */
    protected abstract Icon defineSkillIcon();

    /**技能类型
     * BaseConst.PLAYER_ADV_TAG__SKILLS_SPE; 战斗类技能
     * BaseConst.PLAYER_ADV_TAG__SKILLS_ORD; 生活类技能
     *
     * @return
     */
    protected abstract String defineSkillType();


    /**技能次级类型
     *
     * BaseConst.PLAYER_ADV_SEC_TAG__SKILLS_ONCE; 触发主动技能
     * BaseConst.PLAYER_ADV_SEC_TAG__SKILLS_ACTIVE; 激活/状态技能
     * BaseConst.PLAYER_ADV_SEC_TAG__SKILLS_STATE; 被动技能
     *
     * @return
     */
    protected abstract String defineSkillSecondType();


    /**技能名
     *
     * @return
     */
    protected abstract String defineSkillName();

    /**定义技能所需要的人物等级
     *
     * @return
     */
    protected abstract int defineSkillLevelDependency();

    /**技能描述
     *
     * @return
     */
    public abstract String defineSkillDesc();

    /**技能在所在区域中的 列数 最小1
     *
     * @return
     */
    protected abstract double defineSkillRowX();

    /**技能再所在区域中的 行数 最小1
     *
     * @return
     */
    protected abstract double defineSkillColumnY();

    /**定义技能的冷却时间
     *
     * @return
     */
    protected abstract int defineSkillCoolDown();

    /**定义技能的魔力消耗
     *
     * @return
     */
    protected abstract double defineSkillManaUse();

    /**所依赖的技能名
     *
     * @return
     */
    protected abstract List<String> defineSkillDependencyName();

    //暂不使用
    protected abstract int defineSkillRegion();

    /**定义升级所需要的点数
     *
     * @return
     */
    protected abstract int defineUpgradePoint();





    public String getSkillName() {
        return skillName;
    }

    public void setSkillName(String skillName) {
        this.skillName = skillName;
    }

    public String getSkillType() {
        return skillType;
    }

    public void setSkillType(String skillType) {
        this.skillType = skillType;
    }

    public int getSkillLevel() {
        return skillLevel;
    }

    public void setSkillLevel(int skillLevel) {
        this.skillLevel = skillLevel;
    }

    public boolean isEnable() {
        return isEnable;
    }

    public void setEnable(boolean enable) {
        isEnable = enable;
    }
    public int getLevelDependency() {
        return levelDependency;
    }

    public void setLevelDependency(int levelDependency) {
        this.levelDependency = levelDependency;
    }

    public int getSkillRegion() {
        return skillRegion;
    }

    public void setSkillRegion(int skillRegion) {
        this.skillRegion = skillRegion;
    }

    public String getSkillDesc() {
        return skillDesc;
    }

    public void setSkillDesc(String skillDesc) {
        this.skillDesc = skillDesc;
    }

    public List<String> getSkillsDependencyName() {
        return skillsDependencyName;
    }

    public void setSkillsDependencyName(List<String> skillsDependencyName) {
        this.skillsDependencyName = skillsDependencyName;
    }

    public int getCoolDown() {
        return coolDown;
    }

    public double getManaUse() {
        return manaUse;
    }

    public void setManaUse(double manaUse) {
        this.manaUse = manaUse;
    }

    public void setCoolDown(int coolDown) {
        this.coolDown = coolDown;
    }

    public double getRowX() {
        return rowX;
    }

    public void setRowX(double rowX) {
        this.rowX = rowX;
    }

    public double getColumnY() {
        return ColumnY;
    }

    public void setColumnY(double columnY) {
        ColumnY = columnY;
    }

    public Icon getIcon() {
        return icon;
    }

    public void setIcon(Icon icon) {
        this.icon = icon;
    }

    public String getSkillSecondType() {
        return skillSecondType;
    }

    public void setSkillSecondType(String skillSecondType) {
        this.skillSecondType = skillSecondType;
    }
    public int getUpgradeCount() {
        return upgradeCount;
    }

    public void setUpgradeCount(int upgradeCount) {
        this.upgradeCount = upgradeCount;
    }
}
